<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:doc="livcos.org/ns/doc"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="doc">

  <xsl:template match="doc:list">
    <div id="{@id}">
      <xsl:if test="not(ancestor::doc:list)">
        <xsl:attribute name="class">list</xsl:attribute>
      </xsl:if>
      <ul>
        <xsl:apply-templates select="doc:item" />
      </ul>
    </div>
  </xsl:template>

  <xsl:template match="doc:list[@type = 'ordered']">
    <div id="{@id}">
      <xsl:if test="not(ancestor::doc:list)">
        <xsl:attribute name="class">list</xsl:attribute>
      </xsl:if>
      <ol>
        <xsl:apply-templates select="doc:item" />
      </ol>
    </div>
  </xsl:template>

  <xsl:template match="doc:item">
    <li id="{@id}">
	    <xsl:choose>
	      <xsl:when test="*[@id]">
          <xsl:apply-templates/>
	      </xsl:when>
	      <xsl:otherwise>
	        <span class="inlineEdit">
            <xsl:apply-templates/>
	        </span>
	      </xsl:otherwise>
	    </xsl:choose>
    </li>
  </xsl:template>

</xsl:stylesheet>
